//
//  PreferredGitClientViewController.swift
//  GitTFGUI
//
//  Created by Samuel Richard Magny on 2015-09-25.
//  Copyright © 2015 Samuel Richard Magny. All rights reserved.
//

import Cocoa

class PreferredGitClientViewController: NSViewController {

    @IBOutlet var preferedGitClientPopupButton: NSPopUpButton!
    
    var externalCommitController:ExternalCommitController?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        externalCommitController = ApplicationModel.DefaultApplicationModel.externalCommitController
        
        
        preferedGitClientPopupButton.removeAllItems()
        for client in ExternalCommitController.AvailablePreferedClients
        {
            preferedGitClientPopupButton.addItemWithTitle(client.description)
        }
        
        preferedGitClientPopupButton.selectItemWithTitle(externalCommitController!.preferedGitClient.description)
    }
    
    @IBAction func preferedGitClientButtonClicked(sender: AnyObject) {
        let index = preferedGitClientPopupButton.indexOfSelectedItem
        let selectedClient = ExternalCommitController.AvailablePreferedClients[index]
        externalCommitController!.preferedGitClient = selectedClient
        
    }
    
    
}
